import { http } from './http'
import type { LoginCredentials, RegisterData, LoginResponse, User } from '@/types/user'

export const authApi = {
  login: (credentials: LoginCredentials): Promise<LoginResponse> => {
    return http.post('/auth/login', credentials)
  },

  register: (data: RegisterData): Promise<User> => {
    return http.post('/auth/register', data)
  },

  getCurrentUser: (): Promise<User> => {
    return http.get('/auth/me')
  },

  updateProfile: (data: Partial<User>): Promise<User> => {
    return http.put('/auth/profile', data)
  },

  changePassword: (data: { old_password: string; new_password: string }): Promise<void> => {
    return http.post('/auth/change-password', data)
  }
}